package com.example.yiwei.crm.view.Class.gridViewClass;

/**
 * Created by DHN on 2017/7/20.
 */

public class GetLong {
    public  static final double EARTH_RADIUS = 6378137;
    public static double getlong(double lo1,double la1,double lo2,double la2){
        double lat1 = rad(la1);
        double lat2 = rad(la2);
        double a = rad(la1)-rad(la2);
        double b = rad(lo1)-rad(lo2);
        double s = 2*Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2)+Math.cos(lat1)*Math.cos(lat2)*Math.pow(Math.sin(b/2),2)));
        s= s*EARTH_RADIUS;
        s = Math.round(s*10000)/10000;
        return s;
    }
    public static double rad(double d){

        return d * Math.PI/180.0;
    }
}
